home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC02BusyBox / BusyBox.p / UEvent.p < prev    next >
Encoding:
Text File  |  1990-05-25  |  4.0 KB  |  169 lines  |  [04] ASCII Text (0x0000)

  1. {**********************************************************************
  2. {*
  3. {* BusyBox uEvent -- Version 3.0  (interface)
  4. {*
  5. {* Copyright (c)
  6. {* Apple Computer, Inc.  1986-1989
  7. {* All Rights Reserved.
  8. {*
  9. {* Developer Technical Support Apple II Sample Code
  10. {*
  11. {* This file contains the interface to the code which implements the 
  12. {* main event loop used by the busybox program.
  13. {*
  14. {**********************************************************************}
  15.  
  16. UNIT uEvent;
  17.  
  18. INTERFACE
  19.  
  20. USES
  21.        types,
  22.        GSOS,
  23.        memory,
  24.        locator,
  25.        quickdraw,
  26.        events,
  27.        resources,
  28.        controls,
  29.        windows,
  30.        lineedit,
  31.        dialogs,
  32.        menus,
  33.        stdfile,
  34.        IntMath,
  35.        Fonts,
  36.        Desk,
  37.  
  38.        uGlobals,
  39.        uUtils,
  40.        uWindow,
  41.        uMenu;
  42.  
  43.  
  44.  
  45. procedure MainEvent;   {Main event handling loop which repeats until Quit}
  46.  
  47. IMPLEMENTATION
  48.  
  49. {$R-}
  50.  
  51. var
  52.     LastWindow   : GrafPortPtr;         { This private global is used in CheckFrontW.
  53.                                         { to prevent extra work when the windows
  54.                                         { have not changed.  It is initialized
  55.                                         { at the beginning of MainEvent. }
  56.  
  57.  
  58.  
  59.  
  60. {*******************************************************************}
  61. {
  62. { DoControls
  63. {
  64. { This procedure is called when an inControl message is returned
  65. { by TaskMaster.
  66. {
  67. { When this routine gets control, the ID of the control that was
  68. { hit is in TaskDATA4.  The control handle is in TaskData2 and
  69. { the part code is in taskData 3.
  70. {
  71. {*******************************************************************}
  72. procedure DoControls;
  73. var
  74.     TheID : integer;
  75. begin
  76.     TheID := Event.wmTaskData4;
  77.     if (ButButtonsID <= TheID) and (TheID <= Prog6ID) then
  78.         OpenThisWindow(TheID);
  79. end;
  80.  
  81.  
  82.  
  83. {*******************************************************************}
  84. {
  85. { CheckFrontW
  86. {
  87. { This routine checks the front window to see if any changes need
  88. { to be made to the menu items.
  89. {
  90. { We do this so that the edit items are only active when a desk
  91. { accessory is active.
  92. {
  93. {*******************************************************************}
  94. procedure CheckFrontW;
  95.  
  96. var 
  97.     theWindow    : GrafPortPtr;
  98.  
  99. begin   {of CheckFrontW}
  100.     { Get the front window into local storage.}
  101.     theWindow := FrontWindow;
  102.     
  103.     { If the LastWindow is this window, we are all set. }
  104.     if theWindow = lastWindow then Exit(CheckFrontW);
  105.     
  106.     { If there are no windows, everything should be disabled }
  107.     if theWindow = nil then 
  108.         begin
  109.             SetMenuFlag ($0080,EditMenuID);
  110.             DrawMenuBar;
  111.         end 
  112.     else
  113.         begin
  114.             { Otherwise we look at the window and see what to do. }
  115.             if GetSysWFlag (theWindow) <> false then 
  116.                 begin   {Set up for da windows}
  117.                     SetMenuFlag ($FF7F,EditMenuID);
  118.                     DrawMenuBar;
  119.                 end
  120.             else
  121.                 begin   {Set up for our windows}
  122.                     SetMenuFlag ($0080,EditMenuID);
  123.                     DrawMenuBar;
  124.                 end;
  125.         end;
  126.     
  127.     { Remember this for next time. }
  128.     lastWindow := theWindow;
  129. end;    {of CheckFrontW}
  130.  
  131.  
  132.  
  133.  
  134.  
  135. {************************************************************************
  136. {
  137. { MainEvent
  138. {
  139. { This is the main part of the program.  The program cycles in this
  140. { loop until the user choose select.
  141. {
  142. {************************************************************************}
  143. procedure MainEvent;
  144.  
  145.  
  146. var 
  147.     code : integer;
  148.  
  149.  
  150. begin   {of MainEvent}
  151.    Event.wmTaskMask := $001FFFFF;       { Allow TaskMaster to do everything. }
  152.    Done             := false;           { Done flag will be set by Quit item. }
  153.    LastWindow       := NIL;             { Init this for CheckFrontW. }
  154.  
  155.    repeat
  156.        CheckFrontW;
  157.        code := TaskMaster ($FFFF,Event);
  158.        case code of
  159.            wInGoAway    : DoCloseTop;
  160.            wInSpecial,
  161.            wInMenuBar   : DoMenu;
  162.            wInControl   : DoControls;
  163.        end;
  164.    until Done;
  165. end;    {of MainEvent}
  166.  
  167.  
  168. END.
  169.